﻿using KeZhou.ViewModels;
using KeZhou.Views.Components;
using KeZhou.Views.Components.Controls;
using KeZhou.Views.Components.Customs;
using MahApps.Metro.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace KeZhou.Views
{
    /// <summary>
    /// AppDetailView.xaml 的交互逻辑
    /// </summary>
    public partial class AppDetailView : MetroWindow
    {
        private static AppDetailView instance;

        public static AppDetailView Instance
        {
            get
            {
                return instance;
            }
        }

        private string userAccount;
        public AppDetailView()
        {
            InitializeComponent();
            DataContext = MainSkeletonViewModel.Instance;
            OnSwitchControl(ControlType.MainOne);
            AiColumn.Navigate(MainAi.Instance);
            instance = this;
            this.Topmost = false;
        }

        //展示弹窗方法
        public void showMyMsg(string myMsg)
        {
            MyWarnBox myWarnBox = new MyWarnBox();
            myWarnBox.Owner = this;
            myWarnBox.Show(myMsg);
        }

        //改变模块
        private void StackPanel_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (sender is Grid stackPanel)
            {
                if (stackPanel.Parent is Grid grid)
                {
                    int row = (int)stackPanel.GetValue(Grid.RowProperty);
                    MainSkeletonViewModel.Instance.changeMode(row);
                }
            }
        }

        public void OnSwitchControl(ControlType controlType)
        {
            Application.Current.Dispatcher.Invoke(() =>
            {
                switch (controlType)
                {
                    case ControlType.MainOne:
                        MainContentFrame.Navigate(MainOneGuide.Instance);
                        break;
                    case ControlType.MainTwo:
                        MainContentFrame.Navigate(MainTwoChooseCity.Instance);
                        break;
                    case ControlType.MainThree:
                        MainContentFrame.Navigate(MainThreeInfo.Instance);
                        break;
                    case ControlType.MainFour:
                        MainContentFrame.Navigate(MainFourWishToGo.Instance);
                        TargetManageViewModel.Instance.getAllPlanByAccountId();
                        break;
                    case ControlType.MainFive:
                        MainContentFrame.Navigate(MainFivePlan.Instance);
                        PlanViewModel.Instance.initGetPlanAndAnswer();
                        break;
                    case ControlType.MainSix:
                        MainContentFrame.Navigate(MainSixAccount.Instance);
                        break;
                }
            });
        }

        //展开AI
        public void openAi()
        {
            AiColumn.Width = 260;
        }

        //收起AI
        public void closeAi()
        {
            AiColumn.Width = 0;
        }
    }
}
